﻿using System.Windows;
using System.Windows.Controls;
using GSSoftSL.ViewModel;
using GSSoftSL.Web.Models;

namespace GSSoftSL.Views
{
    /// <summary>
    /// Description for KhoaHocView.
    /// </summary>
    public partial class KhoaHocView : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the KhoaHocView class.
        /// </summary>
        public KhoaHocView()
        {
            InitializeComponent();
        }

        private void btnAddChiTiet_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            KhoaHocViewModel vm = this.DataContext as KhoaHocViewModel;
            KhoaHocChiTiet model = new KhoaHocChiTiet();
            LopChiTietEdit form = new LopChiTietEdit(model, vm.Phongs, vm.CaHocs);
            form.Closed += (o, args) =>
                               {
                                   if (form.IsSubmit)
                                   {
                                       vm.AddBuoiHocCommand.Execute(model);
                                   }
                               };
            form.Show();
        }

        private void btnEditChiTiet_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            KhoaHocViewModel vm = this.DataContext as KhoaHocViewModel;
            if (vm.KhoaHocChiTiet == null)
            {
                MessageWindow.CreateNew("Vui lòng chọn 1 buổi học cần chỉnh sữa.");
                return;
            }
            //KhoaHocChiTiet model = new KhoaHocChiTiet();
            LopChiTietEdit form = new LopChiTietEdit(vm.KhoaHocChiTiet, vm.Phongs, vm.CaHocs);
            form.Show();
        }
        

    }
}